﻿using System.Diagnostics;
using System.Drawing;
using System.Xml;
using System.Xml.Linq;
using NUnit.Framework;

namespace PhotoFramePublishingPlugin.Tests
{
    [TestFixture]
    public class SessionHelperTests
    {
        private static XmlDocument CreateDefaultSessionXml()
        {
            var xml = new XElement("PhotoGalleryPublishSession", new XAttribute("versionMajor", 1),
                                       new XAttribute("versionMinor", 0),
                                       new XElement("PublishParameters",
                                                    new XElement("MaxWidth", 800),
                                                    new XElement("MaxHeight", 600)
                                           )
                );

            var sessionXml = new XmlDocument();
            sessionXml.LoadXml(xml.ToString());

            return sessionXml;
        }

        [Test]
        public void ReadMaxSize_ReturnsCorrectValues()
        {
            XmlDocument sessionXml = CreateDefaultSessionXml();
            Size maximumSize = SessionHelper.ReadMaxSize(sessionXml);
            
            Assert.AreEqual(800, maximumSize.Width);
            Assert.AreEqual(600, maximumSize.Height);
        }
    }
}